<template>
    <div class="page-container">
        <media :query="{minWidth: 768}">
            <div class="pc-media">
                <div class="header-container">
                    <div class="header">
                        <div class="header-top">
                            <div class="header-logo">
                                <img src="../assets/img/logo.png" alt>
                            </div>
                            <div class="nav-list">                               
                                <div class="nav-item">
                                    <a href="#/" style="color:#00bcd4;">活动首页</a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="register-container">
                    <div class="register-content">
                        <register-box/>
                    </div>
                </div>
            </div>
        </media>
        <media :query="{maxWidth: 768}">
            <div class="mb-media">
                <register-box/>
            </div>
        </media>
        <media :query="{minWidth: 768}">
            <footer-nav/>
        </media>
    </div>
</template>

<script>
import $ from 'jquery';
import Media from 'vue-media';
import Footer from '../components/footer';
import RegisterBox from '../components/RegisterBox';
export default {
    name: 'RegisterPage',
    data() {
        return {

        };
    },
    components: {
        'footer-nav': Footer,
        'register-box': RegisterBox,
        Media
    },
    created() {
        if (this.$route.query.code) {
            var that = this;
            $.ajax({
                type: 'GET',
                url: `${that.baseUrl}/api/login/wxlogin?code=${this.$route.query.code}&state=${this.$route.query.state}`,
                success: function(res) {
                    if (res.State) {
                        that.$cookies.set('token', res.Data, 8 * 60 * 60);
                        localStorage.setItem('token', res.Data);
                        that.$store.commit('SET_TOKEN', res.Data);
                        window.location.href = decodeURIComponent(that.$route.query.ReferrerUrl);
                    }
                }
            });
        }
    }
};
</script>

